<!-- 注册 -->
<template>
    <div class="register">
        <div class="title">注  册</div>
        <nut-textinput  v-model="addForm.uid" placeholder="请输入用户名" style="margin-bottom: 20px;"  @keyup.enter.native="handleRegister" />
        <nut-textinput  v-model="addForm.password" placeholder="请输入密码" type="password"  style="margin-bottom: 20px;"  @keyup.enter.native="handleRegister" />
        <nut-textinput  v-model="confirmPassword" placeholder="请确认密码" type="password"  @keyup.enter.native="handleRegister" /><br />
        <nut-textinput  v-model="addForm.nikname" placeholder="请输入昵称" style="margin-bottom: 20px;"   />
        <nut-textinput  v-model="addForm.age" placeholder="请输入年龄" style="margin-bottom: 20px;"   />
        <nut-textinput  v-model="addForm.tel" placeholder="请输入电话" style="margin-bottom: 20px;"   />
        <div class="tip">
            <router-link to="/login">已有账号？前往登录></router-link>
        </div>
        <div class="register-btn" @click="handleRegister">注  册</div>
    </div>
</template>

<script>

import { API_Register } from "@/api/system"

export default {
    data() {
        return {
            addForm: {
                uid: '',
                password: ''
            },
            confirmPassword: ''
        }
    },
    created() {

    },
    mounted() {

    },
    computed: {

    },
    methods: {
        // 注册
        handleRegister() {
            if(!this.addForm.uid) {
                this.$toast.fail('请输入用户名！');
                return;
            }
            if(!this.addForm.password) {
                this.$toast.fail('请输入密码！');
                return;
            }
            if(this.addForm.password !== this.confirmPassword) {
                this.$toast.fail('两次密码不一致！');
                return;
            }
            API_Register(this.addForm).then(res => {
                if(res.data.code === 0) {
                    this.$toast.success('注册成功，请登录！');
                    this.$router.push('/login')
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>

@import "~@/assets/style/helper.scss";

.register {
    width: 100%;
    height: 100%;
    padding: 100px 20px 0;
    .title {
        font-size: 28px;
        font-weight: bold;
        color: $color-highlight;
        margin-bottom: 50px;
    }
    .nut-textinput {
         input {
            border: 1px solid $color-highlight;
        }
    }
    .tip {
        margin-top: 10px;
        color: $color-highlight;
        text-align: right;
        a {
            font-size: 12px;
        }
    }
    .register-btn {
        font-size: 16px;
        color: $color-bgc;
        padding: 13px 24px;
        margin: 20px 10px;
        border: none;
        border-radius: 10px;
        background-color: $color-highlight;
    }
}

</style>